//
//  TimeViewModel.m
//  Futures
//
//  Created by Cheng on 2017/7/11.
//  Copyright © 2017年 Cheng. All rights reserved.
//

#import "TimeViewModel.h"
#import "TimeModel.h"

@implementation TimeViewModel
//传参：symbol,exchange,starttime=2017-07-11 06:00 默认今早
+ (void)requestTimeDataWithSymbol:(NSString *)symbol exchange:(NSString *)exchange block:(void (^)(NSMutableArray *timeArray))block{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateTime = [formatter stringFromDate:[NSDate date]];
    NSString *time = [NSString stringWithFormat:@"%@ 06:00",dateTime];
    
    NSMutableArray *array = [NSMutableArray array];
    
    [Network requestDataMethod:GET WithUrl:URL_FS_DATA parameters:@{@"symbol":symbol,
                                                                    @"exchange":exchange,
                                                                    @"starttime":time} success:^(NSURLSessionDataTask *task, id responseObject) {
                                                                        NSArray *arr = responseObject;
                                                                        for (NSDictionary *dict in arr) {
                                                                            TimeModel *model = [[TimeModel alloc] initWithDict:dict];
                                                                            [array addObject:model];
                                                                        }
                                                                        block(array);
                                                                    } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                                                        MYLog(@"%@",error.description);
                                                                    }];
}
@end


//http://139.224.8.133:9100/api/get_fs_data.ashx?exchange=GLOBEX&starttime=2017-07-11%2006%3A00&symbol=ESU7
//
//http://139.224.8.133:9100/api/get_fs_data.ashx?symbol=CLQ7&exchange=NYMEX&starttime=2017-07-11%2011:22
//
//
//&starttime=2017-07-11%2006%3A00

//&starttime=2017-07-11%2011:22
